﻿using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using Verse;

namespace SZ.Mech
{
    public class CompProperties_DeathSpawn : CompProperties
    {
        public ThingDef Spawn;

        public CompProperties_DeathSpawn()
        {
            compClass = typeof(CompDeathSpawn);
        }
    }

    public class CompDeathSpawn : ThingComp
    {
        public CompProperties_DeathSpawn Properties
        {
            get
            {
                return (CompProperties_DeathSpawn)props;
            }
        }

        public Pawn pawn
        {
            get
            {
                return this.parent as Pawn;
            }
        }



        public override void CompTickRare()
        {
            base.CompTickRare();
            if (pawn.Downed || pawn.Dead)
            {
                

                ThingMaker.MakeThing(Properties.Spawn);
                pawn.Destroy(DestroyMode.Vanish);
            }
        }
    }
}
